<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>
        云客
    </title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="/static/css/x-admin.css" media="all">
    <link rel="stylesheet" href="/static/lib/layui/css/layui.css" media="all">
</head>

<body>
<div class="x-body">
    <form lass="layui-form" id="form1">
        <input type="hidden" name="lid" value="${hl.id}"/>
        <div class="layui-form-item">
            <label for="morgId" class="layui-form-label">
                <span class="x-red">*</span>机构名称
            </label>
            <div class="layui-input-inline">
                <select name="morgId" id="sus" class="layui-input" style="display: block;width: 150px;height: 39px;margin-left: 15px" >
                    <option value="0">请选择机构</option>
                <#list olist as org>
                    <#if hl.orgId==org.id>
                        <option value=${org.id} selected>${org.name}</option>
                    <#else>
                        <option value=${org.id}>${org.name}</option>
                    </#if>
                </#list>
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label for="orgKindName" class="layui-form-label">
                <span class="x-red">*</span>机构级别
            </label>
            <div class="layui-input-inline">
                <input type="text" id="orgKindName" name="orgKindName" readonly="readonly" value="${hl.orgKindName}" required=""
                       autocomplete="off" class="layui-input">
                <input type="hidden" id="orgKindId" name="morgKindId" value="${hl.orgKindId}" />
            </div>
        </div>

        <div class="layui-form-item">
            <label for="province" class="layui-form-label">
                <span class="x-red">*</span>省份
            </label>
            <div class="layui-input-inline">
                <input type="text" id="province" name="province" readonly="readonly" value="${hl.province}" required=""
                       autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label for="city" class="layui-form-label">
                <span class="x-red">*</span>城市
            </label>
            <div class="layui-input-inline">
                <input type="text" id="city" name="city" readonly="readonly" value="${hl.city}" required=""
                       autocomplete="off" class="layui-input">
            </div>
        </div>


        <div class="layui-form-item">
            <label for="moperatorId" class="layui-form-label">
                <span class="x-red">*</span>负责人
            </label>
            <div class="layui-input-inline">
                <select id="operatorId" name="moperatorId" class="layui-input" style="display: block;width: 150px;height: 39px;margin-left: 15px">
                    <option value="0">请选择员工</option>
                <#list slist as staff>
                    <#if hl.operatorId=staff.id>
                        <option value=${staff.id} selected>${staff.name}</option>
                    <#else >
                        <option value=${staff.id}>${staff.name}</option>
                    </#if>
                </#list>
                </select>
            </div>
        </div>

        <div class="layui-form-item">
            <label for="contactName" class="layui-form-label">
                <span class="x-red">*</span>联系人
            </label>
            <div class="layui-input-inline">
                <input type="text" id="contactName" name="contactName" readonly="readonly" value="${hl.contactName}" required=""
                       autocomplete="off" class="layui-input">
                <input type="hidden" id="contactId" name="mcontactId" value="${hl.contactId}" />
            </div>
        </div>

        <div class="layui-form-item">
            <label for="contactTel" class="layui-form-label">
                <span class="x-red">*</span>联系人电话
            </label>
            <div class="layui-input-inline">
                <input type="text" id="contactTel" name="contactTel" readonly="readonly" value="${hl.contactTel}" required="" lay-verify="phone"
                       autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label for="mownerId" class="layui-form-label">
                <span class="x-red">*</span>日志所属人
            </label>
            <div class="layui-input-inline">
                <select id="ownerId" name="mownerId" class="layui-input" style="display: block;width: 150px;height: 39px;margin-left: 15px">
                    <option value="0">请选择员工</option>
                <#list slist as staff>
                    <#if hl.ownerId=staff.id>
                        <option value=${staff.id} selected>${staff.name}</option>
                    <#else >
                        <option value=${staff.id}>${staff.name}</option>
                    </#if>
                </#list>
                </select>
            </div>
        </div>

        <div class="layui-form-item">
            <label for="mproId" class="layui-form-label">
                <span class="x-red">*</span>日志所属人
            </label>
            <div class="layui-input-inline">
                <select id="proId" name="mproId" class="layui-input" style="display: block;width: 150px;height: 39px;margin-left: 15px">
                    <option value="0">请选择产品</option>
                <#list plist as pro>
                    <#if hl.proId==pro.id>
                        <option value=${pro.id} selected>${pro.proName}</option>
                    <#else >
                        <option value=${pro.id}>${pro.proName}</option>
                    </#if>
                </#list>
                </select>
            </div>
        </div>

        <div class="layui-form-item">
            <label for="proState" class="layui-form-label">
                <span class="x-red">*</span>产品状态
            </label>
            <div class="layui-input-inline">
                <input type="text" id="proState" name="proState" readonly="readonly" value="${hl.proState}" required=""
                       autocomplete="off" class="layui-input">
            </div>
        </div>


        <div class="layui-form-item">
            <label for="mlevelId" class="layui-form-label">
                <span class="x-red">*</span>日志等级
            </label>
            <div class="layui-input-inline">
                <select id="mlevelId" name="mlevelId" class="layui-input" style="display: block;width: 150px;height: 39px;margin-left: 15px">
                    <option value="0">请选择日志级别</option>
                <#if hl.levelId==1>
                    <option value="1" selected>一般日志</option>
                    <option value="2">重要日志</option>
                    <option value="3">无效日志</option>
                <#elseif hl.levelId==2>
                    <option value="2" selected>重要日志</option>
                    <option value="1">一般日志</option>
                    <option value="3">无效日志</option>
                <#elseif hl.levelId==3>
                    <option value="3" selected>无效日志</option>
                    <option value="1">一般日志</option>
                    <option value="2">重要日志</option>
                <#else >
                    <option value="3">无效日志</option>
                    <option value="1">一般日志</option>
                    <option value="2">重要日志</option>
                </#if>
                </select>
            </div>
        </div>

        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">日志内容</label>
            <div class="layui-input-block">
                <textarea id="logcontent" name="content" class="layui-textarea">${hl.content}</textarea>
            </div>
        </div>
        <div>

            <div class="layui-form-item">
                <label for="checkState" class="layui-form-label">
                    <span class="x-red">*</span>审核状态
                </label>
                <div class="layui-input-inline">
                    <select id="checkState" name="checkState" class="layui-input" style="display: block;width: 150px;height: 39px;margin-left: 15px">
                        <option value="0">请选择审核状态</option>
                    <#if hl.checkState=="未审核">
                        <option selected>未审核</option>
                        <option>审核中</option>
                        <option>已审核</option>
                    <#elseif hl.checkState=="审核中">
                        <option>未审核</option>
                        <option selected>审核中</option>
                        <option>已审核</option>
                    <#elseif hl.checkState=="已审核">
                        <option>未审核</option>
                        <option>审核中</option>
                        <option selected>已审核</option>
                    <#else>
                        <option>未审核</option>
                        <option>审核中</option>
                        <option>已审核</option>
                    </#if>
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="datestring" class="layui-form-label">
                    <span class="x-red">*</span>日志日期
                </label>
            <div class="layui-inline">
                <input class="layui-input" id="datestring" name="datestring" value="${hl.datostr}" onclick="layui.laydate({elem: this, festival: true})">
            </div>
                </div>
            <div>
                <button type="button" id="conf" lay-filter="add" lay-submit="">确定</button>
                <button type="reset" id="res">取消</button>
            </div>
    </form>
</div>
<script src="/static/lib/layui/layui.js" charset="utf-8">
</script>
<script src="/static/js/x-layui.js" charset="utf-8">
</script>
<script src="/static/js/jquery.min.js">
</script>
<script>

    layui.use('laydate', function(){
        var laydate = layui.laydate;

        var start = {
            min: laydate.now()
            ,max: '2099-06-16 23:59:59'
            ,istoday: false
            ,choose: function(datas){
                end.min = datas; //开始日选好后，重置结束日的最小日期
                end.start = datas //将结束日的初始值设定为开始日
            }
        };

        var end = {
            min: laydate.now()
            ,max: '2099-06-16 23:59:59'
            ,istoday: false
            ,choose: function(datas){
                start.max = datas; //结束日选好后，重置开始日的最大日期
            }
        };
    });
    layui.use(['form','layer'], function(){
        $ = layui.jquery;
        var form = layui.form()
                ,layer = layui.layer;
        form.on('submit(add)', function(data){
            //发异步，把数据提交给php
            var path = "";
            var msg ="";
            if ('${hl}' != '') {
                path = "/handlelog/updatehandlelog";
                msg ="修改成功";
            } else {
                path = "/handlelog/inserthandlelog";
                msg ="新增成功";
            }
           /* $("#form1").attr("action", path).submit();*/
            $.ajax({
                type:"POST",
                url:path,
                data:$("#form1").serialize()
            });
            layer.alert(msg, {icon: 6},function () {
                var index = parent.layer.getFrameIndex(window.name);
                //关闭弹出层
                parent.layer.close(index);
                parent.window.location.href="/handlelog/alllogs";
            });
            return false;
        });
        //自定义验证规则
        form.verify({
            nikename: function(value){
                if(value.length < 5){
                    return '昵称至少得5个字符啊';
                }
            }
            ,pass: [/(.+){6,12}$/, '密码必须6到12位']
            ,repass: function(value){
                if($('#L_pass').val()!=$('#L_repass').val()){
                    return '两次密码不一致';
                }
            }
        });
    })

</script>
<script>
    var _hmt = _hmt || [];
    (function() {
        var hm = document.createElement("script");
        hm.src = "https://hm.baidu.com/hm.js?b393d153aeb26b46e9431fabaf0f6190";
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(hm, s);
    })();
</script>

<script>
    $(function () {
        $("#sus").click(function () {
            $.ajax({
                type: "GET",
                url: "/handlelog/searchorgname",
                data: "morgId=" + $("#sus").val(),
                success: function (data) {
                    $("#orgKindName").val(data.orgKindName);
                    $("#province").val(data.province);
                    $("#city").val(data.city);
                    $("#contactName").val(data.contactName);
                    $("#contactId").val(data.contactId);
                    $("#contactTel").val(data.contactTel);
                    $("#orgKindId").val(data.orgKindId);
                }
            })
        });

        $('#proId').click(function () {
            $.ajax({
                type: "GET",
                url: "/handlelog/getrelproduct",
                data: "proId=" + $("#proId").val(),
                success: function (data) {
                    $("#proState").val(data.proState);
                }
            })
        });
        if ('${hl}' != '') {
            $("#ttitle").html("<h5>修改日志</h5>");
        } else {
            $("#ttitle").html("<h5>新增日志</h5>");
        }

        $("#conf").attr("disabled", true);
        $("select").each(function () {
            if ($(this).val() != null && $(this).val() != 0) {
                $("#conf").attr("disabled", false);
            }
        });

        $("select").click(function () {
            $("#conf").attr("disabled", false);
            $("select").each(function () {
                if ($(this).val() == null || $(this).val() == 0) {
                    $("#conf").attr("disabled", true);
                }
            });
        });
    })
</script>
</body>

</html>